package com.im.project.controller;

import com.im.common.result.JsonResult;
import com.im.project.service.MinioFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * minio文件 控制层
 *
 * @author yunZhouJiaDi
 */
@RestController
@RequestMapping("/file")
@Api(tags = "MinioFileController", description = "minio文件相关接口")
public class MinioFileController {

    @Resource
    private MinioFileService minioFileService;

    @PostMapping("/upload")
    @ApiOperation("单上传")
    public JsonResult uploadFile(@RequestPart("file") MultipartFile file) {
        return JsonResult.success(minioFileService.upload(file));
    }

    @PostMapping("/uploadFiles")
    @ApiOperation("多上传")
    public JsonResult uploadFiles(@RequestParam("files") MultipartFile[] files) {
        return JsonResult.success(minioFileService.uploadFiles(files));
    }

}
